<#include "/common/include.html"/>
<@pageTheme mark="${config.optimize()?string('true', 'false')}">
<@header title="导入表结构"/>
<@search fromId="gen-form">
					<input id="dbName"   name="dbName"    type="hidden" value="${dbName}"/>
					<div class="select-list">
						<ul>
							<li>
								表名称：<select name="tableName" class="form-control">
									<option value="">所有</option>
									<#list dbTables>
										<#items as d>
											<option value="${d.tableName}">${d.tableName}</option>
										</#items>
									</#list>
								</select>
							</li>
							<li>
								表描述：<select name="tableComment" class="form-control">
									<option value="">所有</option>
									<#list dbTables>
										<#items as d>
											<option value="${d.tableComment}">${d.tableComment}</option>
										</#items>
									</#list>
								</select>
							</li>
							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="opt.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
</@search>
<@table tableId="bootstrap-table"/>
<@footer>
	<script type="text/javascript">
		var prefix = baseURL + "tool/gen";

		function queryParams(params) {
			console.log(params);
			var search = $.table.queryParams(params);
			search.dbName = $("#dbName").val();
			return search;
		}

		$(function() {
		    var options = {
		        url: prefix + "/db/list",
		        sortName: "create_time",
		        sortOrder: "desc",
		        showSearch: false,
		        showRefresh: false,
		        showToggle: false,
		        showColumns: false,
		        clickToSelect: true,
				queryParams: this.queryParams, /*初始化请求参数*/
				pageSize: 10,
				pageList: [10, 30, 50],
		        columns: [{
		            checkbox: true
		        },
		        {
                    title: $.i18n.prop("序号"),
                    formatter: function (value, row, index) {
                 	    return $.table.serialNumber(index);
                    }
                },
		        {
		            field: 'tableName',
		            title: '表名称',
		            width: '20%',
		            sortable: true
		        },
		        {
		            field: 'tableComment',
		            title: '表描述',
		            width: '20%',
		            sortable: true
		        },
		        {
		            field: 'createTime',
		            title: $.i18n.prop("创建时间"),
		            width: '20%',
		            sortable: true
		        },
		        {
		            field: 'updateTime',
		            title: '更新时间',
		            width: '20%',
		            sortable: true
		        }]
		    };
		    $.table.init(options);
		});
		
		/* 导入表结构-选择表结构-提交 */
		function submitHandler() {
			var rows = $.table.selectColumns("tableName");
			if (rows.length == 0) {
       			opt.modal.alertWarning("请至少选择一条记录");
       			return;
       		}
			var data = {"tables": rows.join(),"dbName": $("#dbName").val()};
			opt.operate.save(prefix + "/importTable", data);
		}
	</script>
</@footer>
</@pageTheme>